package com.yonyou.cyxdms.sysAuth.service.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yonyou.cyx.framework.dao.base.SuperMapper;
import com.yonyou.cyxdms.sysAuth.service.entity.role.RolePO;
import com.yonyou.cyxdms.sysAuth.service.vo.employee.FindRolePositionVO;
import com.yonyou.cyxdms.sysAuth.service.vo.employee.FindRoleVO;
import com.yonyou.cyxdms.sysAuth.service.vo.role.RolePageVO;
import com.yonyou.cyxdms.sysAuth.service.vo.role.RoleVO;
import com.yonyou.cyxdms.sysmanage.client.vo.role.UserbyRoleVO;
import org.apache.ibatis.annotations.Param;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 角色信息 Mapper 接口
 * </p>
 *
 * @author quankk
 * @since 2019-07-05
 */
public interface RoleMapper extends SuperMapper<RolePO> {
    /**
     * 分页条件查询角色
     *
     * @author dengqiang
     * @since 2019/7/9
     */
    List<RolePageVO> pageRole(@Param("page") Page<RolePageVO> page, @Param("params") Map<String, Object> queryCondition, @Param("companyType") Integer companyType, @Param("factoryId") Integer factoryId);

    /**
     * 是否可分配
     *
     * @author dengqiang
     * @since 2019/7/9
     */
    public Map<String, Object> selectIsFixed();

    public List<Map<String, String>> queryByRoleIds(Integer roleId);

    List<Map<String, Object>> queryRoleId(@Param("roleId") Long roleId, @Param("appId") String appId);

    // @Param("list")List<String> fromUserIds
    List<Map<String, Object>> findAllPermissionCtrl(@Param("permissionType") Integer permissionType, @Param("list") List<String> ids, @Param("isEmpowered") Integer isEmpowered, @Param("appId") String appId);

    List<Map<String, Object>> findAllCommonTree(@Param("orgType") Integer orgType, @Param("appId") String appId, @Param("list") List<String> list, @Param("permissionType") Integer permissionType, @Param("dataSource") Integer dataSource, @Param("dataType") Integer dataType);

    List<Map<String, Object>> findTreeMenuAction(@Param("list") List<String> list, @Param("permissionType") Integer permissionType);

    List<Map<String, Object>> findTreeMenuRange(@Param("list") List<String> list, @Param("permissionType") Integer permissionType);

    void deleteA(@Param("permissionId") Long permissionId);

    void deleteR(@Param("permissionId") Long permissionId);

    void deleteC(@Param("permissionId") Long permissionId, @Param("permissionType") Integer permissionType);

    public Integer deleteRoleById(@Param("permissionId") Long permissionId);

    List<Map<String, Object>> selectPermissionMenuId(@Param("id") Long id, @Param("billTypePermissionRole") Integer billTypePermissionRole);

    List<Map<String, Object>> selectPermissionCtrlId(@Param("permissionId") Long permissionId, @Param("permissionType") Integer permissionType);

    List<Map<String, Object>> selctMenuId(@Param("menuID") Long menuId);

    void updatePermissionMenu(@Param("permissionType") Integer permissionType, @Param("permissionId") Integer permissionId, @Param("menuID") Long menuId, @Param("isEmpowered") Integer isEmpowered);

    List<Map<String, Object>> selectTmpermissionMenu(@Param("menuID") String menuId, @Param("permissionId") String permissionId, @Param("permissionType") Integer permissionType);

    List<Map<String, Object>> queryMenuOne();

    List<Map<String, Object>> queryMenuTwo();

    Integer updateRoleNameById(@Param("roleName") String roleName, @Param("roleId") Integer roleId);

    Integer updateRoleNameByIds(@Param("roleName") String roleName, @Param("isValid") Integer isValid, @Param("roleId") Integer roleId);

    List<UserbyRoleVO> getUserInfoByRole(@Param("params") Map<String, Object> params, @Param("ownerCode") String ownerCode, @Param("roleCodes") String[] roleCodes);

    Long selectByCode(@Param("roleCode") String roleCode);

    List<FindRoleVO> findRole(@Param("employeeNo") String employeeNo, @Param("companyId") Long companyId, @Param("orgId") Long orgId);

    List<FindRolePositionVO> findRoleByCodes(@Param("userOrgId") Long userOrgId, @Param("list") List<Integer> list);

    List<FindRoleVO> findAllRole(@Param("companyId") Long companyId, @Param("companyType") Integer companyType, @Param("factoryId") Integer factoryId, @Param("appId") String appId,@Param("roleType")Integer roleType);

    List<Long> findUserRoleIds(@Param("employeeNo") String employeeNo, @Param("orgId") Long orgId);

    void searchBrandCode(Map map);
   void  deleteRolePosition(@Param("permissionId") Long permissionId);

    List<RolePageVO> getUserRoleName(@Param("page") Page<RolePageVO> page, @Param("params") Map<String, Object> queryCondition);

    Integer selectByRoleId(@Param("roleCode") String roleCode, @Param("appId") String appId);

    ArrayList<RoleVO> getPresetRole(@Param("companyId") Long companyId, @Param("dataSource") Integer dataSource, @Param("dataType") Long dataType);

    List<RoleVO> getPresetRoleByName(@Param("list") List<String> names);
}
